<%@ page language="java" pageEncoding="UTF-8"%>
<c:if test="${page.totalItems>0}">
    <%-- 这个一定要在外部定义 
	<c:set var="requestPath" value="${base }/user/buyer/order?${pageContext.request.queryString}" />
	<c:set var="aLinkTitle" value="翻页超链接的title" />
	--%>
    <c:choose>
        <c:when test="${param.pageNo!=null && param.pageNo!=''}">
            <%--页码参数字符串 --%>
            <c:set var="pParam" value="&pageNo=${param.pageNo}" />
            <%--当前页码 --%>
            <c:set var="nowPageNo" value="${param.pageNo}" />
        </c:when>
        <c:otherwise>
            <c:set var="pParam" value="&pageNo=1" />
            <c:set var="nowPageNo" value="1" />
        </c:otherwise>
    </c:choose>
    <%-- 没有页码的请求路径--%>
   <%--  <c:set var="noPagePath" value="${fn:replace(fn:replace(requestPath, pParam,''),'&pageNo=','')}" /> --%>
    <%--设置总页数 --%>
    <c:set var="totalPage" value="${page.totalPages}"></c:set>
    <c:if test="${totalPage>100}">
        <c:set var="totalPage" value="100"></c:set>
    </c:if>
    <div class="pageTop">
        <div class="pageonediv">
            <div id="Pagination">
                <div class="pagination" id="widthObj">
                    <%--小于七页 --%>
                    <c:if test="${totalPage<=6 && totalPage>1}">
                        <c:forEach begin="1" end="${totalPage}" varStatus="index">
                            <c:choose>
                                <c:when test="${nowPageNo==index.index}">
                                    <span class="current" title="${aLinkTitle}">${index.index }</span>
                                </c:when>
                                <c:otherwise>
                                    <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${index.index}${urlHash}">${index.index }</a>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </c:if>
                    <%--大于六页 --%>
                    <c:if test="${totalPage>6}">
                        <c:choose>
                            <c:when test="${nowPageNo==1}">
                                <span title="${aLinkTitle}" class="prev">上一页</span>
                                <%-- 								<span title="${aLinkTitle}" class="current prev">上一页</span> --%>
                            </c:when>
                            <c:otherwise>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo-1}${urlHash}" class="prev">上一页</a>
                            </c:otherwise>
                        </c:choose>
                        <c:choose>
                            <%--页号小于四 --%>
                            <c:when test="${nowPageNo<=4}">
                                <c:forEach begin="1" end="6" varStatus="index">
                                    <c:choose>
                                        <c:when test="${nowPageNo==index.index}">
                                            <span title="${aLinkTitle}" class="current">${index.index }</span>
                                        </c:when>
                                        <c:otherwise>
                                            <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${index.index}${urlHash}">${index.index }</a>
                                        </c:otherwise>
                                    </c:choose>
                                </c:forEach>
                                <span>...</span>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${totalPage}${urlHash}">${totalPage}</a>
                            </c:when>
                            <%--页号大于四 --%>
                            <c:when test="${nowPageNo>4 && nowPageNo<=totalPage-5}">
                                <%-- 页号大于四  --%>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=1${urlHash}">1</a>
                                <span>...</span>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo-2}${urlHash}">${nowPageNo-2}</a>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo-1}${urlHash}">${nowPageNo-1}</a>
                                <span title="${aLinkTitle}" class="current">${nowPageNo}</span>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo+1}${urlHash}">${nowPageNo+1}</a>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo+2}${urlHash}">${nowPageNo+2}</a>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo+3}${urlHash}">${nowPageNo+3}</a>
                                <span>...</span>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${totalPage}${urlHash}">${totalPage}</a>
                            </c:when>
                            <c:when test="${nowPageNo > totalPage-5}">
                                <%-- 页号大于最后五个  --%>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=1${urlHash}">1</a>
                                <span>...</span>
                                <c:forEach begin="${totalPage-5}" end="${totalPage}" varStatus="index">
                                    <c:choose>
                                        <c:when test="${nowPageNo==index.index}">
                                            <span title="${aLinkTitle}" class="current">${index.index }</span>
                                        </c:when>
                                        <c:otherwise>
                                            <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${index.index}${urlHash}">${index.index }</a>
                                        </c:otherwise>
                                    </c:choose>
                                </c:forEach>
                            </c:when>
                        </c:choose>
                        <c:choose>
                            <c:when test="${nowPageNo==totalPage}">
                                <span title="${aLinkTitle}" class="next">下一页</span>
                                <%-- 								<span title="${aLinkTitle}" class="current next">下一页</span> --%>
                            </c:when>
                            <c:otherwise>
                                <a title="${aLinkTitle}" href="${noPagePath}&pageNo=${nowPageNo+1}${urlHash}" class="next">下一页</a>
                            </c:otherwise>
                        </c:choose>
                    </c:if>
                </div>
            </div>
        </div>
    </div>
</c:if>
<!--[if lt IE 8]>
<script type="text/javascript">
 var widthObj=document.getElementById("widthObj");
 //widthObj.style.position="absolute";
 widthObj.style.width=widthObj.children.length*50+"px"; //js设置div宽度
 //alert( widthObj.style.width);
</script>
<![endif]-->
